Note search enables you to find notes by searching for text in the title, content, or attributes of the notes. You also have the option to save your searches, which will create a special search note which is visible on your navigation tree and contains the search results as sub-items.
There are multiple types of searches, all using the same search mechanism and query language:
Quick search which can be found in the Launch Bar for small one-off searches.
Full search is the more advanced search mechanism.
Some Collections such as board view have a dedicated search bar which applies to that collection.
To search for notes, click on the magnifying glass icon on the toolbar or press the keyboard shortcut.
To help with the syntax, Trilium offers an autocomplete functionality which can be triggered by pressing Ctrl+Space.
Some suggestions also open on their own as you type: label and relation
names after # and ~, fields after .,
operators, values, and notes after @. Keywords such as and, or, not, orderBy and limit appear
only on Ctrl+Space, since a plain word is usually
a search term.
No suggestion is selected when the list opens, so Enter runs the search as typed. To insert a suggestion, select it with Down and press Enter.
The autocomplete offers:
Basic operators such as *= and keywords (limit, not).
Fields for object-like fields such as note or ~relation,
triggered by typing ..
Contextual enumerations such as note.type = " or note.mime = ".
Label names by typing #,
with user-defined ones shown first.
Relation names by typing ~.
Note IDs can be inserted easily
by typing @ and looking for a note.
~template.noteId = @
The search input features syntax highlighting, making recognized fields
such as note. and operators like NOT stand out.
The search is also checked for errors in two phases, which will be displayed as a red squiggle:
An error the search only runs into while running, such as an operator that note content cannot be searched with, is shown in a Search error card instead: below the search string, or at the top of the Quick search results.
Long or complicated searches can be formatted by using newlines, similar to SQL queries. Newlines are treated just like spaces.
To add a new line, press Shift+Enter.
Click on which search option to apply from the Add search option section.
The options available are:
Results appear below the search pane as a list of snippet cards. Each card shows the note title and a short excerpt of the text that matched.
The search will also highlight the words from the title or content that matched:
In addition:
searchResultsPageSize option), so you do not
have to reset it on every device.rings tolkien: Full-text search to find notes containing
both "rings" and "tolkien"."The Lord of the Rings" Tolkien: Full-text search where "The
Lord of the Rings" must match exactly.note.content *=* rings OR note.content *=* tolkien: Find
notes containing "rings" or "tolkien" in their content.towers #book: Combine full-text and attribute search to find
notes containing "towers" and having the "book" label.towers #book or #author: Search for notes containing "towers"
and having either the "book" or "author" label.towers #!book: Search for notes containing "towers" and not
having the "book" label.#book #publicationYear = 1954: Find notes with the "book"
label and "publicationYear" set to 1954.#genre *=* fan: Find notes with the "genre" label containing
the substring "fan". Additional operators include *=* for "contains", =* for
"starts with", *= for "ends with", and != for "is
not equal to".#book #publicationYear >= 1950 #publicationYear < 1960:
Use numeric operators to find all books published in the 1950s.#dateNote >= TODAY-30: Find notes with the "dateNote"
label within the last 30 days. Supported date values include NOW +- seconds,
TODAY +- days, MONTH +- months, YEAR +- years.~author.title *=* Tolkien: Find notes related to an author
whose title contains "Tolkien".#publicationYear %= '19[0-9]{2}': Use the '%=' operator to
match a regular expression (regex). This feature has been available since
Trilium 0.52.note.content %= '\\d{2}:\\d{2} (PM|AM)': Find notes that
mention a time. Backslashes in a regex must be escaped.~author.relations.son.title = 'Christopher Tolkien': Search
for notes with an "author" relation to a note that has a "son" relation
to "Christopher Tolkien". This can be modeled with the following note structure:
~author.title *= Tolkien OR (#publicationDate >= 1954 AND #publicationDate <= 1960):
Use boolean expressions and parentheses to group expressions. Note that
expressions starting with a parenthesis need an "expression separator sign"
(# or ~) prepended.note.parents.title = 'Books': Find notes with a parent named
"Books".note.parents.parents.title = 'Books': Find notes with a grandparent
named "Books".note.ancestors.title = 'Books': Find notes with an ancestor
named "Books".note.children.title = 'sub-note': Find notes with a child
named "sub-note".See also Under the hood for more syntax references.
Notes have properties that can be used in searches, such as noteId, dateModified, dateCreated, isProtected, type, title, text, content, rawContent, ownedLabelCount, labelCount, ownedRelationCount, relationCount, ownedRelationCountIncludingLinks, relationCountIncludingLinks, ownedAttributeCount, attributeCount, targetRelationCount, targetRelationCountIncludingLinks, parentCount, childrenCount, isArchived, contentSize, noteSize,
and revisionCount.
These properties can be accessed via the note. prefix, e.g., note.type = code AND note.mime = 'application/json'.
#author=Tolkien orderBy #publicationDate desc, note.title limit 10
This example will:
publicationDate in descending order.note.title as a secondary ordering if publication dates
are equal.Some queries can only be expressed with negation:
#book AND not(note.ancestors.title = 'Tolkien')
This query finds all book notes not in the "Tolkien" subtree.
See the dedicated page to understand how progressive search works in Trilium, as well as some advanced use cases.
You can open Trilium and automatically trigger a search by including the search url encoded string in the URL:
http://localhost:8080/#?searchString=abc
| Parameter | Value | Description |
|---|---|---|
MIN_FUZZY_TOKEN_LENGTH
|
3 | Minimum characters the ~= and ~* operators accept |
MAX_EDIT_DISTANCE
|
2 | Ceiling on character changes, reached only by 7+ character terms; shorter terms allow fewer. See the Fuzzy tolerance section above |
RESULT_SUFFICIENCY_THRESHOLD
|
5 | Minimum exact results before fuzzy fallback |
MAX_CONTENT_SIZE
|
10MB | Maximum note content size for search processing |